package com.ruoyi.web.controller.counter;

import java.util.Date;
import java.util.List;

import com.ruoyi.counter.domain.CounterStatisticalList;
import com.ruoyi.counter.service.ICounterStatisticalListService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工器具领取归还汇总Controller
 *
 * @author xll
 * @date 2021-10-12
 */
@RestController
@RequestMapping("/counterstatistical")
public class CounterStatisticalListController extends BaseController
{
    @Autowired
    private ICounterStatisticalListService counterStatisticalListService;

    /**
     * 查询工器具领取归还汇总列表
     */
    @PreAuthorize("@ss.hasPermi('counterstatistical:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(CounterStatisticalList counterStatisticalList)
    {
        startPage();
        List<CounterStatisticalList> list = counterStatisticalListService.selectCounterStatisticalListList(counterStatisticalList);
        return getDataTable(list);
    }

    /**
     * 导出工器具领取归还汇总列表
     */
    @PreAuthorize("@ss.hasPermi('counterstatistical:list:export')")
    @Log(title = "导出工器具领取归还汇总", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CounterStatisticalList counterStatisticalList)
    {
        List<CounterStatisticalList> list = counterStatisticalListService.selectCounterStatisticalListList(counterStatisticalList);
        ExcelUtil<CounterStatisticalList> util = new ExcelUtil<CounterStatisticalList>(CounterStatisticalList.class);
        Date date=new Date();
          long dateTime=date.getTime();
        System.out.println(dateTime);
        return util.exportExcel(list, "工器具领取归还汇总数据");
    }

    /**
     * 获取工器具领取归还汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('counterstatistical:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(counterStatisticalListService.selectCounterStatisticalListById(id));
    }

    /**
     * 新增工器具领取归还汇总
     */
    @PreAuthorize("@ss.hasPermi('counterstatistical:list:add')")
    @Log(title = "工器具领取归还汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CounterStatisticalList counterStatisticalList)
    {
        return toAjax(counterStatisticalListService.insertCounterStatisticalList(counterStatisticalList));
    }

    /**
     * 修改工器具领取归还汇总
     */
    @PreAuthorize("@ss.hasPermi('counterstatistical:list:edit')")
    @Log(title = "工器具领取归还汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CounterStatisticalList counterStatisticalList)
    {
        return toAjax(counterStatisticalListService.updateCounterStatisticalList(counterStatisticalList));
    }

    /**
     * 删除工器具领取归还汇总
     */
    @PreAuthorize("@ss.hasPermi('counterstatistical:list:remove')")
    @Log(title = "工器具领取归还汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(counterStatisticalListService.deleteCounterStatisticalListByIds(ids));
    }
}
